Kotlin Essentials by Marcin Moskała

Kotlin Essentials by Marcin Moskała

Author:Marcin Moskała [Marcin Moskała]
Language: eng
Format: epub, pdf
Publisher: leanpub.com
Published: 2022-08-30T00:00:00+00:00


In practice, object expressions are used as an alternative to Java anonymous classes, i.e., when we need to create a watcher or a listener with multiple handler methods.

taskNameView.addTextChangedListener(object : TextWatcher { override fun afterTextChanged( editable: Editable? ) { //... } override fun beforeTextChanged( text: CharSequence?, start: Int, count: Int, after: Int ) { //... } override fun onTextChanged( text: CharSequence?, start: Int, before: Int, count: Int ) { //... } })

Note that “object expression” is a better name than “anonymous class” since this is an expression that produces an object.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.